package com.zd.springcloud.consumer.controller;

import com.zd.springcloud.consumer.service.AccountService;
import com.zd.springcloud.consumer.tccaction.AccountAction;
import io.seata.rm.tcc.api.BusinessActionContextUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/account")
public class AccounController {

    @Autowired
    AccountAction accountAction;

    @PutMapping("/reduceMoney")
    public String reduceMoney(@RequestParam("money")double money, @RequestParam("accountId") long accountId){
        accountAction.reduceMoney(BusinessActionContextUtil.getContext(),money,accountId);
        return "success";

    }
}
